var router = require('koa-router')();

// 访问地址的前缀
router.prefix('/api/user');

router.post('/login', function *(next) {
  const { username, password } = this.request.body
  this.body = {
    errno: 0,
    username,
    password
  }
});

router.get('/session-test', function *(next) {
  if(this.session.viewCount===null) {
    this.session.viewCount = 0
  }
  const viewCount = this.session.viewCount++
  this.body = {
    errno: 0,
    viewCount
  }
})

module.exports = router;
